/**
 * controller_other.js
 * 其他控制器
 * 
 * @author 	王中艺	<wangzy_smile@qq.com>
 * @date 	2017-05-28
 */

//vip会员介绍
app.controller('PlatInfoVipIntro', function($scope, $http, $location, $timeout, common){
	//变量声明
	$scope.vipIntro 	= '';
	$scope.loading 	= false;

	var tVipIntro;

	//初始化JS
	$scope.init_js 	= function(){
		tVipIntro 	= common.createEditor('vip-intro');
	}

	//加载数据
	$scope.get_item 	= function(){
		var url 	= config.prefix_url + '/PlatInfo/getVipIntro';
		$http.get(url).success(function(info){
			$scope.loading 	= false;
			console.log(info);
			if(info.code != 1){
				common.dealError(info);
				return false;
			}

			$scope.vipIntro 	= info.data.info;
			tVipIntro.$txt.html($scope.vipIntro);
		})
		$scope.loading 	= true;
	}

	//保存数据
	$scope.save_item 	= function(){
		var url 	= config.prefix_url + '/PlatInfo/updateVipIntro';
		var param 	= {
			'vip_intro'	: tVipIntro.$txt.html()
		}

		$http.post(url, param).success(function(info){
			$scope.loading 	= false;
			console.log(info);
			if(info.code != 1){
				common.dealError(info);
				return false;
			}

			common.doAlert('更改成功!');
		})
		$scope.loading 	= true;
	}

	$scope.init_js();
	$scope.get_item();
})

//晨间家长必读
app.controller('PlatInfoMorningParentWill', function($scope, $http, $location, $timeout, common){
	//变量声明
	$scope.parentWill 	= '';
	$scope.loading 	= false;

	var tParentWill;

	//初始化JS
	$scope.init_js 	= function(){
		tParentWill 	= common.createEditor('parent-will');
	}

	//加载数据
	$scope.get_item 	= function(){
		var url 	= config.prefix_url + '/PlatInfo/getMorningParentWill';
		$http.get(url).success(function(info){
			$scope.loading 	= false;
			console.log(info);
			if(info.code != 1){
				common.dealError(info);
				return false;
			}

			$scope.parentWill 	= info.data.info;
			tParentWill.$txt.html($scope.parentWill);
		})
		$scope.loading 	= true;
	}

	//保存数据
	$scope.update_item 	= function(){
		var url 	= config.prefix_url + '/PlatInfo/updateMorningParentWill';
		var param 	= {
			'info'	: tParentWill.$txt.html()
		}

		$http.post(url, param).success(function(info){
			$scope.loading 	= false;
			console.log(info);
			if(info.code != 1){
				common.dealError(info);
				return false;
			}

			common.doAlert('更改成功!');
		})
		$scope.loading 	= true;
	}

	$scope.init_js();
	$scope.get_item();
})
//晚间家长必读
app.controller('PlatInfoEveningParentWill', function($scope, $http, $location, $timeout, common){
	//变量声明
	$scope.parentWill 	= '';
	$scope.loading 	= false;

	var tParentWill;

	//初始化JS
	$scope.init_js 	= function(){
		tParentWill 	= common.createEditor('parent-will');
	}

	//加载数据
	$scope.get_item 	= function(){
		var url 	= config.prefix_url + '/PlatInfo/getEveningParentWill';
		$http.get(url).success(function(info){
			$scope.loading 	= false;
			console.log(info);
			if(info.code != 1){
				common.dealError(info);
				return false;
			}

			$scope.parentWill 	= info.data.info;
			tParentWill.$txt.html($scope.parentWill);
		})
		$scope.loading 	= true;
	}

	//保存数据
	$scope.update_item 	= function(){
		var url 	= config.prefix_url + '/PlatInfo/updateEveningParentWill';
		var param 	= {
			'info'	: tParentWill.$txt.html()
		}

		$http.post(url, param).success(function(info){
			$scope.loading 	= false;
			console.log(info);
			if(info.code != 1){
				common.dealError(info);
				return false;
			}

			common.doAlert('更改成功!');
		})
		$scope.loading 	= true;
	}

	$scope.init_js();
	$scope.get_item();
})
     